import {
  ShapeCustomizationManagementModel,
  ShapeStyleValue
} from "@/modules/model/modals/shapeCustomization/ShapeCustomizationManagementModel";
import { markRaw } from "vue";
import ColorFillComps from "@/modules/model/modals/shapeCustomization/comps/valueComps/ColorFillComps.vue";
import CheckBoxComps from "@/modules/model/modals/shapeCustomization/comps/valueComps/CheckBoxComps.vue";
import NumberInputComps from "@/modules/model/modals/shapeCustomization/comps/valueComps/NumberInputComps.vue";
import RightAngleComps from "@/modules/model/modals/shapeCustomization/comps/valueComps/RightAngleComps.vue";
import FontFamilyComps from "@/modules/model/modals/shapeCustomization/comps/valueComps/FontFamilyComps.vue";
import FontSizeComps from "@/modules/model/modals/shapeCustomization/comps/valueComps/FontSizeComps.vue";
import FontPatternComps from "@/modules/model/modals/shapeCustomization/comps/valueComps/FontPatternComps.vue";

export const valueCompsMap = {
  rightAngle: markRaw(RightAngleComps),
  strokeColor: markRaw(ColorFillComps),
  strokeWidth: markRaw(NumberInputComps),
  rounded: markRaw(CheckBoxComps),
  dashed: markRaw(CheckBoxComps),
  fontFamily: markRaw(FontFamilyComps),
  fontSize: markRaw(FontSizeComps),
  color: markRaw(ColorFillComps),
  fontStyle: markRaw(FontPatternComps)
};

export const shapeStyleInfo: ShapeStyleValue[] = [
  {
    enName: "Line Style",
    enTips: "",
    key: "rightAngle",
    name: "连线形状",
    value: true
  },
  {
    enName: "Stroke Color",
    enTips: "",
    key: "strokeColor",
    name: "连线颜色",
    value: ""
  },
  {
    enName: "Stroke Width",
    enTips: "",
    key: "strokeWidth",
    name: "连线粗细",
    value: undefined
  },
  {
    enName: "is Rounded",
    enTips: "",
    key: "rounded",
    name: "连线折角是否为圆弧",
    value: false
  },
  {
    enName: "is Dashed",
    enTips: "",
    key: "dashed",
    name: "连线是否为虚线",
    value: false
  },
  {
    enName: "Context font family",
    enTips: "",
    key: "fontFamily",
    name: "上下文字体",
    value: ""
  },
  {
    enName: "Context font size",
    enTips: "",
    key: "fontSize",
    name: "上下文字号",
    value: undefined
  },
  {
    enName: "Context font color",
    enTips: "",
    key: "color",
    name: "上下文颜色",
    value: ""
  },
  {
    enName: "Context font style",
    enTips: "",
    key: "fontStyle",
    name: "上下文字形",
    value: ""
  }
];

export class ShapeLineStyleConfigModel {
  shapeStyleInfo = shapeStyleInfo;
  shapeStyleMap = new Map<string, ShapeStyleValue>();
  constructor(public shapeCustomizationManagementModel: ShapeCustomizationManagementModel) {
    shapeStyleInfo.forEach(v => {
      this.shapeStyleMap.set(v.key, v);
    });
  }

  initLineStyleConfig(row) {
    for (const key in row) {
      if (this.shapeStyleMap.get(key)) {
        this.shapeStyleMap.get(key)!.value = row[key];
      }
    }
  }
}
